import React, { Component } from 'react'
//1.引入PropTypes(如需下载,直接引入)
import PropTypes from 'prop-types'

export default class List extends Component {
  // 2. 给当前组件添加静态属性propsTypes
  static propTypes = {
    // 3. 给指定属性添加校验规则
    arr: PropTypes.array.isRequired, // arr的值必须是数组,并且必须传递
  }
  render() {
    return (
      <ul>
        {this.props.arr.map((item) => {
          return <li key={item}>{item}</li>
        })}
      </ul>
    )
  }
}
